Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

373
Vistas
Match "And" if the preceding sentence has an "and"

Basically, I want to do this:

Text and text text. Text text. And text. (Don't match this "And.")
Text and text text. And text. (Match this "And.")

Right now, I have this regex: .*\b(and)\b.*\. And. But it matches both And's in the example above: https://regexr.com/65k52

How to modify this regex so it only matches And if the previous sentence has and?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want to use . + whitespace as a sentence separator sequence you can use

(?=\S)[^.]*(?:\.(?!\s)[^.]*)*?\band\b[^.]*(?:\.(?!\s)[^.]*)*\.\s+And\b
(?=\S)(?:[^.]|\.(?!\s))*?\band\b(?:[^.]|\.(?!\s))*\.\s+And\b

See the regex demo #1 and regex demo #2. Details:

  • (?=\S) - next char must be a non-whitespace
  • (?:[^.]|\.(?!\s))*? - zero or more (but as few as possible) occurrences of any one char other than . or a . that is not immediately followed with whitespace
  • \band\b - whole word and
  • (?:[^.]|\.(?!\s))* - zero or more (but as many as possible) occurrences of any one char other than . or a . that is not immediately followed with whitespace
  • \. - a dot
  • \s+ - one or more whitespaces
  • And\b - a whole word And.
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda